package com.example.back.controller;

import com.example.back.dto.req.DrugTabooEditReq;
import com.example.back.dto.req.DrugTabooListReq;
import com.example.back.dto.resp.DrugTabooListResp;
import com.example.back.service.DrugTabooService;
import com.example.common.support.Result;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 用药禁忌
 */
@RestController
@Api(tags = "用药禁忌")
@RequestMapping("/DConfig/DrugTaboo")
public class DrugTabooController {
    @Resource
    private DrugTabooService drugTabooService;

    @ApiOperation(value = "获取用药禁忌列表", notes = "获取用药禁忌列表")
    @PostMapping(value = "/list")
    public Result<PageInfo<DrugTabooListResp>> list(@RequestBody DrugTabooListReq req) {
        return Result.success(drugTabooService.list(req));
    }

    @ApiOperation(value = "修改和添加用药禁忌", notes = "修改和添加用药禁忌")
    @PostMapping(value = "/commitSave")
    public Result<Object> commitSave(@RequestBody DrugTabooEditReq req) {
        return Result.success(drugTabooService.commitSave(req));
    }

    @ApiOperation(value = "删除用药禁忌", notes = "删除用药禁忌")
    @PostMapping(value = "/commitDel")
    public Result<Object> commitDel(@RequestBody DrugTabooEditReq req) {
        return Result.success(drugTabooService.commitDel(req));
    }
}
